<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <title>dc-example</title>
    <script src="/libs/dc-sdk/dc.min.js"></script>
    <link href="/libs/dc-sdk/dc.min.css" type="text/css" rel="stylesheet" />
    <link href="../index.css" type="text/css" rel="stylesheet" />
  </head>

  <body>
    <div id="viewer-container" class="viewer-container"></div>
    <div class="btn-box">
      <ul>
        <li><button onclick="draw('point')">点</button></li>
        <li><button onclick="draw('billboard')">图标点</button></li>
        <li><button onclick="draw('polyline')">线</button></li>
        <li><button onclick="draw('polygon')">面</button></li>
        <li><button onclick="draw('circle')">圆</button></li>
        <li><button onclick="draw('rect')">矩形</button></li>
        <li><button onclick="draw('attack_arrow')">进攻箭头</button></li>
        <li><button onclick="draw('double_arrow')">双箭头</button></li>
        <li><button onclick="draw('fine_arrow')">直箭头</button></li>
        <li><button onclick="draw('tailed_attack_arrow')">燕尾箭头</button></li>
        <li><button onclick="draw('gathering_place')">聚集地</button></li>
        <li><button onclick="draw('bezier_curve')">曲线</button></li>
        <li><button onclick="removeAll()">清除</button></li>
      </ul>
    </div>
    <script>
      DC.config.baseUrl = '../libs/dc-sdk/resources/'
      let viewer = new DC.Viewer('viewer-container')
      let baseLayer = DC.ImageryLayerFactory.createImageryLayer(
        DC.ImageryType.AMAP,
        {
          style: 'img',
          crs: 'WGS84',
        }
      )
      viewer.addBaseLayer(baseLayer)
      let layer = new DC.VectorLayer('layer')
      viewer.addLayer(layer)
      let plot = new DC.Plot(viewer)

      function draw(type) {
        plot &&
          plot.draw(type, (overlay) => {
            if (overlay) {
              layer.addOverlay(overlay)
              plot.edit(overlay)
            }
          })
      }

      function removeAll() {
        layer.clear()
      }
    </script>
  </body>
</html>
